package com.wc2;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class NewMapper extends Mapper<LongWritable, Text, Text, IntWritable> {

    private Text mKey = new Text();
    private IntWritable mval = new IntWritable(1);

    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, IntWritable>.Context context) throws IOException, InterruptedException {
        String[] wordArr = value.toString().split(" ");

        for (String word : wordArr) {
            mKey.set(word);
            context.write(mKey, mval);
        }

    }
}
